<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/

get_config_keytable("user_views_");
empty($do) && $do = 'list';
if ($do == 'list') {
	$id = getGP('userid','G','int');
	$rs = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."user a,".DB_TABLEPRE."user_view b WHERE a.id=b.uid and a.id=".$id."");
	include_once('template/file.php');

}
///////////////////////////////////////////////////////////////////

function get_document_list($fatherid=0,$selid=0,$layer=0)
{

    
    global $db;
	$query = $db->query("SELECT * FROM ".DB_TABLEPRE."department where father='$fatherid'  ORDER BY id Asc  ");
	
	if(count($query)>0){
	   //for($i=0;$i<$layer;$i++){
	   
	   //$str.="<TD class=MemoTD width=20>&nbsp;</TD>";
	   
	   //}
	while ($row = $db->fetch_array($query)) {
	$rsfno = $db->fetch_one_array("SELECT * FROM ".DB_TABLEPRE."department where father='".$row[id]."'  ORDER BY id asc limit 0,1");

	echo "a.add(".$row[id].",".$fatherid.",'".$row[name]."','#');";

	if($rsfno[id]!=''){
	get_document_list($row['id'],$selid,$layer+1);
	}else{
	
	get_user_list($row['id']);
	
	
	}
	}
	}
	
   return ;

}
//================================================================
//调用档案
function get_user_list($did=0)
{
$treedatenum=get_date('Y',PHP_TIME).get_date('m',PHP_TIME).get_date('d',PHP_TIME).get_date('H',PHP_TIME).get_date('i',PHP_TIME).get_date('s',PHP_TIME);
global $db;
$query = $db->query("SELECT a.id,b.name FROM ".DB_TABLEPRE."user a,".DB_TABLEPRE."user_view b WHERE a.id=b.uid and a.departmentid='".$did."' ORDER BY a.id ASC ");
			while ($row = $db->fetch_array($query)) {
			echo "a.add(".$treedatenum.$row[id].",".$did.",'".$row[name]."','admin.php?ac=file&fileurl=user&userid=".$row[id]."');";
			}
}
?>